package com.jgp.glmeeting.service.impl;

import com.jgp.glmeeting.model.MeetingParticipantsRelation;
import com.jgp.glmeeting.repository.MeetingParticipantsRelationRepository;
import com.jgp.glmeeting.service.MeetingParticipantsRelationService;
import com.jgp.sys.common.query.Operator;
import com.jgp.sys.common.query.QueryFilterList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MeetingParticipantsRelationServiceImpl implements MeetingParticipantsRelationService {

    @Autowired
    private MeetingParticipantsRelationRepository meetingParticipantsRelationRepository;


    @Override
    public void addMeetingParticipantsRelation(MeetingParticipantsRelation r) {
        meetingParticipantsRelationRepository.createOrUpdate(r);
    }

    @Override
    public List<MeetingParticipantsRelation> queryUsersIDs(String meetingID) {
        QueryFilterList queryFilterList=new QueryFilterList();
        queryFilterList.addFilter("meetingId","eq",meetingID);
        return meetingParticipantsRelationRepository.read(queryFilterList);
    }

    @Override
    public long deleteByMeetingId(String meetingId) {
        return meetingParticipantsRelationRepository.delete(new QueryFilterList().addFilter("meetingId", Operator.eq, meetingId));
    }

    @Override
    public void removeById(String id) {
        meetingParticipantsRelationRepository.delete(id);
    }

    @Override
    public List<MeetingParticipantsRelation> queryMeetingParticipantsRelation(String participantsId,String meetingID) {
        QueryFilterList queryFilterList=new QueryFilterList();
        queryFilterList.addFilter("participantsId","eq",participantsId);
        queryFilterList.addFilter("meetingId","eq",meetingID);

        return meetingParticipantsRelationRepository.read(queryFilterList);
    }
}
